package com.numberone.web.controller.goodsDetail;

import com.numberone.common.page.TableDataInfo;
import com.numberone.framework.web.base.BaseController;
import com.numberone.system.domain.GoodDetailList;
import com.numberone.system.domain.GoodsDetail;
import com.numberone.system.service.IGoodsDetailService;
import com.numberone.system.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 商品规格 信息操作处理
 *
 * @author 郭财源
 * @date 2020-09-28
 */
@Controller
@RequestMapping("/api/goodsDetail")
public class GoodsDetailApiController extends BaseController {
    @Autowired
    private IGoodsDetailService goodsDetailService;

    /**
     * 根据商品获取对应的规格信息
     * @author 郭财源
     * @param goodsId
     * @return
     */
    @ResponseBody
    @PostMapping("/getGoodsDetail")
    public JsonResult getGoodsDetail(Long goodsId)
    {
        List<GoodsDetail> goodsDetails = goodsDetailService.selectGoodsDetailByGood(goodsId);
        TableDataInfo dataTable = getDataTable(goodsDetails);
//        GoodDetailList goodDetailList = goodsDetailService.selectGoodsDetailByGood(goodsId);
        return JsonResult.success(goodsDetails);
    }
}
